<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <title>班级查询</title>
    <link href="/resources/bootstrap-3.3.5-dist/css/bootstrap.min.css" title="" rel="stylesheet"/>
    <link title="" href="/resources/css/style.css" rel="stylesheet" type="text/css"/>
    <link title="blue" href="/resources/css/dermadefault.css" rel="stylesheet" type="text/css"/>
    <link href="/resources/css/templatecss.css" rel="stylesheet" title="" type="text/css"/>
    <script src="/resources/script/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="/resources/script/jquery.cookie.js" type="text/javascript"></script>
    <script src="/resources/bootstrap-3.3.5-dist/js/bootstrap.min.js" type="text/javascript"></script>

    <style>
        .dropdown-submenu {
            position: relative;
        }

        .dropdown-submenu > .dropdown-menu {
            top: 0;
            left: 60%;
            margin-top: 26px;
            margin-left: -1px;
            -webkit-border-radius: 0 6px 6px 6px;
            -moz-border-radius: 0 6px 6px;
            border-radius: 0 6px 6px 6px;
        }

        .dropdown-submenu:hover > .dropdown-menu {
            display: block;
        }

        .dropdown-submenu > a:after {
            display: block;
            content: " ";
            float: right;
            width: 0;
            height: 0;
            border-color: transparent;
            border-style: solid;
            border-width: 5px 0 5px 5px;
            border-left-color: #ccc;
            margin-top: 5px;
            margin-right: -10px;
        }

        .dropdown-submenu:hover > a:after {
            border-left-color: #fff;
        }

        .dropdown-submenu.pull-left > .dropdown-menu {
            left: -100%;
            margin-left: 10px;
            -webkit-border-radius: 6px 0 6px 6px;
            -moz-border-radius: 6px 0 6px 6px;
            border-radius: 6px 0 6px 6px;
        }

    </style>
    <script type="text/javascript">
        $(function () {
            var insertmessage = "<%=session.getAttribute("insertmessage")%>";
            var editmassage = "<%=session.getAttribute("editmassage")%>";
            console.log("===insertmessage提示信息====" + insertmessage)
            console.log("===editmassage提示信息====" + editmassage)
            if (insertmessage == "success") {
                alert("添加成功！");
            }
            if (insertmessage == "isRepete") {
                alert("已存在，请重新添加！");
            }
            if (insertmessage == "isEmpty") {
                alert("数据为空，请重新填写！");
            }
            if (editmassage == "success") {
                alert("修改成功！");
            }
            if (editmassage == "error") {
                alert("数据为空，请重新填写！");
            }
        })
    </script>
</head>

<body>
<%@ include file="head.jsp" %>
<div class="down-main">
   <%@ include file="left.jsp" %>
    <div class="right-product view-product right-full">
        <div class="container-fluid">
            <div class="info-center">
                <div class="page-header">
                    <div class="pull-left">
                        <h4><strong style="font-family: STXingkai;font-size: 30px; ">班级信息查询</strong></h4>
                    </div>
                    <div class="pull-right">
                        <a href="/class/goAddClass" class="btn btn-info"
                           style="position: relative; margin: 10px;">添加班级</a>
                    </div>
                </div>

                <div class="indentify-class padding-lr">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-9 fadeInLeft table-responsive">
                                <table class="table table-responsive table-hover" align="center">
                                    <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>党组织名称</th>
                                        <th>组织类别</th>
                                        <th>党组织书记</th>
                                        <th>党组织联系人</th>
                                        <th>联系电话</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody id="htmlDiv">
                                    <c:if test="${classPageInfo.list.size() ==0}">
                                                                        <tr>
                                                                            <td colspan="9" align="center">暂无数据...</td>
                                                                        </tr>
                                                                    </c:if>
                                    <c:forEach var="classes" items="${classPageInfo.list}">
                                        <tr>
                                            <td>${classes.classId}</td>
                                            <td><span data-toggle="tooltip" title="党组织名称">${classes.className}</span>
                                            </td>
                                            <td><span data-toggle="tooltip" title="党组织类别">${classes.classId}</span>
                                            </td>
                                            <td><span data-toggle="tooltip" title="联系人">${classes.mark}</span>
                                            </td>
                                            <td><span data-toggle="tooltip" title="创建时间">${classes.createTime}</span>
                                            </td>
                                            <td>
                                                <a href="javascript:void(0);" onclick="edits(${classes.classId})"
                                                   class="btn btn-success btn-xs"
                                                   style=""><span class="glyphicon glyphicon-ok"
                                                                  aria-hidden="true"></span>查看-修改</a>
                                                <a href="javascript:void(0);" onclick="deletes(${classes.classId})"
                                                   class="btn btn-danger btn-xs"
                                                   style=""><span class="glyphicon glyphicon-remove"
                                                                  aria-hidden="true"></span>删除</a>
                                            </td>

                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                    <tfoot id="page">

                                    <tr>
                                        <td colspan="7" align="right">
                                            当前${classPageInfo.pageNum }页,总${classPageInfo.pages }页,总${classPageInfo.total }条记录
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="7" align="right">
                                            <ul class="pagination">
                                                <li><a
                                                    href="/class/queryClass?page=1">首页</a>
                                                </li>
                                                <!-- 判断是否有上一页，以便显示点击按钮 -->
                                                <c:if test="${classPageInfo.hasPreviousPage }">
                                                    <li>
                                                        <a href="/class/queryClass?page=${classPageInfo.pageNum-1 }"
                                                           aria-label="Previous">
                                                            <span aria-hidden="true">&laquo;</span>
                                                        </a>
                                                    </li>
                                                </c:if>
                                                <!-- 遍历页码 -->
                                                <c:forEach items="${classPageInfo.navigatepageNums }"
                                                           var="page_Num">
                                                    <c:if test="${page_Num == classPageInfo.pageNum }">
                                                        <li class="active"><a href="#">${page_Num }</a></li>
                                                    </c:if>
                                                    <c:if test="${page_Num != classPageInfo.pageNum }">
                                                        <li><a
                                                            href="/class/queryClass?page=${page_Num }">${page_Num}</a>
                                                        </li>
                                                    </c:if>
                                                </c:forEach>
                                                <!-- 判断是否有下一页 -->
                                                <c:if test="${classPageInfo.hasNextPage }">
                                                    <li>
                                                        <a href="/class/queryClass?page=${classPageInfo.pageNum+1 }"
                                                           aria-label="Next">
                                                            <span aria-hidden="true">&raquo;</span>
                                                        </a>
                                                    </li>
                                                </c:if>

                                                <li>
                                                    <a href="/class/queryClass?page=${classPageInfo.pages }">末页</a>
                                                </li>
                                            </ul>

                                        </td>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        /*左侧导航栏显示隐藏功能*/
        $(".subNav").click(function () {
            /*显示*/
            if ($(this).find("span:first-child").attr('class') == "title-icon glyphicon glyphicon-chevron-down") {
                $(this).find("span:first-child").removeClass("glyphicon-chevron-down");
                $(this).find("span:first-child").addClass("glyphicon-chevron-up");
                $(this).removeClass("sublist-down");
                $(this).addClass("sublist-up");
            }
            /*隐藏*/
            else {
                $(this).find("span:first-child").removeClass("glyphicon-chevron-up");
                $(this).find("span:first-child").addClass("glyphicon-chevron-down");
                $(this).removeClass("sublist-up");
                $(this).addClass("sublist-down");
            }
// 修改数字控制速度， slideUp(500)控制卷起速度
            $(this).next(".navContent").slideToggle(300).siblings(".navContent").slideUp(300);
        })
        /*左侧导航栏缩进功能*/
        $(".left-main .sidebar-fold").click(function () {

            if ($(this).parent().attr('class') == "left-main left-full") {
                $(this).parent().removeClass("left-full");
                $(this).parent().addClass("left-off");

                $(this).parent().parent().find(".right-product").removeClass("right-full");
                $(this).parent().parent().find(".right-product").addClass("right-off");

            } else {
                $(this).parent().removeClass("left-off");
                $(this).parent().addClass("left-full");

                $(this).parent().parent().find(".right-product").removeClass("right-off");
                $(this).parent().parent().find(".right-product").addClass("right-full");

            }
        })
        })

        /*左侧鼠标移入提示功能*/
        $(".sBox ul li").mouseenter(function () {
            if ($(this).find("span:last-child").css("display") == "none") {
                $(this).find("div").show();
            }
        }).mouseleave(function () {
            $(this).find("div").hide();
        });

        $("[data-toggle='tooltip']").tooltip();
    })

    //查看-修改
    function edits(id) {
        // alert(id + "==========");
        location.replace("/party/goEditParty?partyId=" + id)
    }

    //删除
    function deletes(id) {
        // alert(id + "==========");
        if (confirm("请确认操作")) {
            $.ajax({
                url: '/party/removeParty',
                data: {
                    partyId: id,
                },
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if (data.errno == 0) {
                        alert(data.message);
                        location.reload()
                    } else {
                        alert(data.message);
                    }
                }
            });
        } else {
            location.reload()
        }
    }

    function pages(data) {
        var html = '';
        html += '<input type="text" id="partyName" style="display: none" value="' + data.list[0].ClassName + '"/>' +
            '<tr><td colspan="7" align="center">当前' +
            data.pageNum + '页,总' + data.pages + '页,总' + data.total + '条记录</td></tr>' +
            '<tr><td colspan="7" align="center"><ul class="pagination">' +
            '<li><a class="pageCount" name="1">首页</a></li>';
//判断是否有上一页
        if (data.hasPreviousPage) {
            html += '<li><a class="pageCount" name="' + data.prePage + '" aria-label="Previous">' +
                '<span aria-hidden="true">&laquo;</span></a></li>';
        }
//遍历一共有几页数据
        for (var i = 0; i < data.navigatepageNums.length; i++) {
            //console.log(data.navigatepageNums[i]);
            if (data.navigatepageNums[i] == data.pageNum) {
                html +=
                    '<li class="active"><a href="#">' + data.navigatepageNums[i] + '</a></li>'
            } else {
                html +=
                    '<li><a href="#" class="pageCount" name="' + data.navigatepageNums[i] + '">' + data.navigatepageNums[i] + '</a></li>'
            }
        }
        //判断是否有下一页
        if (data.hasNextPage) {
            html += '<li><a class="pageCount" name="' + data.nextPage + '" aria-label="Next">' +
                '<span aria-hidden="true">&raquo;</span></a></li>';
        }
        //最后一页
        html +=
            '<li><li>' +
            '<a class="pageCount" name="' + data.pages + '">末页</a>' +
            '</li></ul></tr>';
        $("#page").html(html);
    };

</script>
</body>
</html>
